import { onMounted, ref } from 'vue';

import { getDictTree } from '@/api/dict';

export const useTree = () => {
  const treeData = ref([]);
  const defaultProps = ref({
    children: 'children',
    label: 'name',
  });

  const getTreeData = async () => {
    const res = await getDictTree({});
    console.log(res);
    treeData.value = res;
  };

  onMounted(() => {
    getTreeData();
  });

  return {
    defaultProps,
    treeData,
  };
};
